﻿using Microsoft.Extensions.Logging;
using Simple.Framework.Configuration;
using Simple.Tools;
//using Simple.WindowsServer;
using SimpleNet;
using SimpleNet.example;
using SimpleNet.example.Inter;
using SimpleNet.example.schedule;
using SimpleNet.Handle;
using SimpleNet.Net;
using SimpleNet.Protocol;
using System.Reflection;
using System.Security.Cryptography;

public class Program
{
	public static int Main(string[] args)
	{

		var hosts=ToolSimpleCheck.GetLocalHosts();

		//foreach (var item in hosts)
		//{
  //          Console.WriteLine(item);
  //      }

		ISimpleBuilder host = SimpleBuilder.BuilderHost().Regster((container) =>
		{
			//容器模块，注册需要实例的对象，容器可以自动创建对象，解决对象的依赖。
			//container.RegisterSingleton<IMessageHandle, IDTMessageHandle>();
			//container.Register<IContext, IDTContext>();
			//container.RegisterSingleton<IRedisClientService, RedisClientService>();
			//container.Register<VersionUpgradeHanlder>();
			//container.RegisterSingleton<IConfiguration,MyConfiguration>();
			var configuration = container.GetService<IConfiguration>();
			container.Register(typeof(UserA)).Autowird();
			var a=container.GetService(typeof(UserA));
			//container.RegisterSingleton<IPretty, ExtPretty>().Autowird();
			string rPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"TEST.Repository.dll");
			string irPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"TEST.IRepository.dll");
			if (File.Exists(rPath))
			{
			}
			if (File.Exists(irPath))
			{
			}
			Assembly assembly = Assembly.LoadFile(rPath);
			Assembly Iassembly = Assembly.LoadFile(irPath);
			container.RegisterAssambly(Iassembly,assembly).Autowird();
			#region 扩展部分

			#endregion
			//umxkmh2pcs
		}).
			ConfigutionLogger((logerProvide) =>
			{

				#region 日志模块配置
				if (ToolSimpleCheck.IsDebug())
				{
					logerProvide.CurrentLogLevel = LogLevel.Trace; //大于debug 等级日志将会被打印
				}
				else
				{
					logerProvide.CurrentLogLevel = LogLevel.Information; //大于debug 等级日志将会被打印
				}

				//logerProvide.CurrentLogLevel = LogLevel.Warning;
				logerProvide.IsConsoleWrite = true;
				logerProvide.RollingInterval = Simple.Framework.Logger.eRollingInterval.Day;//每天创建一份日志文件
				logerProvide.ProfixLogFile = "service";//日志文件名称前缀
				logerProvide.LogFolderPath = "log";//日志文件夹相对路径
				#endregion
			}).ConfigutionMessageHandle<MyMessageHandle>()
		.StartPrettyServer();
		    //UseWindowsService();

		Console.ReadLine();
		return 0;
	}
}